07. RViz Basics

What is RViz?

RViz (or rviz) stands for ROS Visualization tool or ROS Visualizer. RViz is our one stop tool to visualize all three core aspects of a robot: Perception, Decision Making, and Actuation.

Using rviz, you can visualize any type of sensor data being published over a ROS topic like camera images, point clouds, ultrasonic measurements, Lidar data, inertial measurements, etc. This data can be a live stream coming directly from the sensor or pre-recorded data stored as a bagfile.

You can also visualize live joint angle values from a robot and hence construct a real-time 3D representation of any robot. Having said that, rviz is not a simulator and does not interface with a physics engine, in other words no collisions and no dynamics. RViz is not an alternative to Gazebo but a complementary tool to keep an eye on every single process under the hood of a robotic system.

Since rviz is a ROS package, you need roscore running to launch rviz. In a terminal spin up roscore:

$ roscore

In another terminal, run rviz:

$ rosrun rviz rviz

Once properly launched, rviz window should look something like this:

The empty window in the center is called 3D view, this is where you will spend most of your time observing the robot model, sensor visualization and other meta-data.

The panel on the left is a list of loaded Displays, while the one on the right shows different Views available.

On the top we have a number of useful tools and bottom bar displays useful information like time elapsed, fps count, and some handy instructions/details for the selected tool.

Displays

For anything to appear in the 3D view, you first need to load a proper display. A display could be as simple as a basic 3D shape or a complex robot model.

Displays can also be used to visualize sensor data streams like 3D pointclouds, lidar scans, depth images, etc.

Rviz by default starts up with two fixed property fields that cannot be removed - Global Options and Global Status. While these are not displays, one governs simple global settings, while the other detects and displays useful status notifications.

Let us play around with a few basic displays. As you can see we already have a Grid display loaded and enabled. To add a robot model display, you first need to load the robot description (remember urdf?) into the parameter server and publish transform between all the robot links. Luckily, we have a convenient launch file that does all of this for us, open a new terminal and type in the following command:

$ roslaunch kuka_arm load_urdf.launch

Now let's go back to the rviz window and add a display by clicking the Add button at the bottom. This will bring up a new window with display types, select RobotModel and hit Ok. Next change the Fixed Frame under Global Options from world (or map) to base_link.

If everything works fine, you should be able to see the robot model:

You can disable a display type without having to remove it completely by simply unchecking the check-box right next to it. Enable again by checking the check-box.

Feel free to play around with different display types and their properties but remember, for most display types to work, you need to load up a corresponding source.

Views

We have several view types in rviz which basically change the camera type in the 3D view. Remember for each view type, instructions on how to rotate, pan, and zoom using your mouse can be seen at the bottom status bar. We will discuss three widely used camera types here:

Orbit

In the orbit view, you set a Focal point and the camera simply rotates around that focal point always looking at it. While moving, you can see the focal point in the form of a yellow disk.

FPS

FPS view is a first person camera view. Just like a FPS video game, the camera rotates as if rotating about your head.

TopDownOrtho

This camera always looks down along the global Z axis, restricting your camera movement to the XY plane. Mostly used while performing 2D navigation for mobile robots.

Again feel free to play around with these and other view types, remember if you get lost in the vast nothingness of the rviz 3D view, you can always switch back your camera to the origin of world frame by clicking the zero button next to the view type.

Toolbar

Next we will explore some of the tools present in the top toolbar on the rviz window. While most of these tools are generic and can be used for any robot, some are specific to mobile robot navigation and will be covered in future lessons.

Move Camera

This is the most basic and often default tool used to, as you guessed it, move the camera. Remember that movement control changes from one view type to another, again refer the movement table for a quick comparison of the controls.

Select

To demonstrate this tool, let us add a new panel called the “Selection Panel”. To do this, click on "Panels" on the top menu of rviz window and then click on “Selection”, you should now see an empty Selection panel on top of the displays panel. Now select the "Select" tool from the toolbar. Using this tool you can select a single item by left clicking it or box select multiple items by clicking and dragging. Details of your selection are displayed in the Selection panel. e.g. selecting a robot link will provide you with its current Pose (Position + Orientation). This tool comes in handy in complex environments, where you want to determine the properties or status of one or more items.

Focus Camera

As the name suggests, this tool allows you to bring any item or part of a robot in ”focus”, meaning at the center of the 3D view panel by left clicking it once.

Measure

Upon activation this tool allows you to measure the distance between two points in the 3D view. You can set the starting point by one left click and then set the end point by second left click. The measured distance between these two points will be shown at the bottom status bar of the rviz window. Remember though, you cannot measure the distance between two points in the empty space. You must have some object present for you to click.

Interact

This is a special tool that can be used to interact with interactive markers. More on interactive markers can be learned here. To better understand this, let us open a preconfigured rviz session for motion planning with our Kuka KR210 arm. Close the existing rviz session by selecting the terminal that you used to launch rviz and pressing Ctlr+C. Now type in:

$ roslaunch kr210_claw_moveit demo.launch

You should get something like this:

Since this is a preconfigured rviz session, you will find that few tools are missing and there are a lot of display types that you do not recognize.

You need not worry about any of those, we will cover this in great details in motion planning lessons. For now select the interact tool if it is not already selected, now you can see a complex 3D marker around the gripper on the arm, this is called an interactive marker.

Now try to grab the marker and move it around. Isn’t this beautiful? The robot changes its configuration to adjust to new end-effector position guided by your mouse as long as the end-effector pose falls into valid robot workspace. Feel free to play around a bit.

You can close this demo by pressing Ctrl+C in the launch terminal.